import java.util.LinkedList;

public class PCB {
  /* extra stuff */
  private String processName; // added this extra
  private int outstandingResourceRequests = 0; // total number of resources
					       // allocated
  /* extra stuff */

  private int pid;
  private int statusType; // running, ready, blocked, ready_s, blocked_s
  // running: running n CPU
  // ready: ready to run, waiting
  // blocked: waiting for resource

  private LinkedList<RCB> otherResources = new LinkedList<RCB>(); // points to
								  // resources
								  // it is
								  // allocated

  private PCB parent;
  private LinkedList<PCB> children;

  // priority:
  // 0,1,2 (init, user, system)
  private int priority;

  private LinkedList<PCB> statusList; // point to ReadyList, or WaitingList in a
				      // RCB

  public int getPriority() {
    return priority;
  }

  public int getStatusType() {
    return statusType;
  }

  public void setStatusType(int statusType) {
    this.statusType = statusType;
  }

  public int getPid() {
    return pid;
  }

  public PCB getParent() {
    return parent;
  }

  public LinkedList<PCB> getChildrenList() {
    return children;
  }

  // constructor, create()
  public PCB(int priority, PCB parent, String processName) {
    children = new LinkedList<PCB>();
    this.setProcessName(processName);

    
    pid = OSystem.getNextPid();
    OSystem.incrementNextPid();

    this.priority = priority;
    statusType = OSystem.READY_S;
    this.parent = parent;

  }

  public LinkedList<RCB> getOtherResources() {
    return otherResources;
  }

  public LinkedList<PCB> getStatusList() {
    return statusList;
  }

  public void setStatusList(LinkedList<PCB> statusList) {
    this.statusList = statusList;
  }

  public String getProcessName() {
    return processName;
  }

  public void setProcessName(String processName) {
    this.processName = processName;
  }

  public boolean equals(Object other) {
    if (this == other) {
      return true;
    }
    if (other instanceof PCB) {
      PCB others = (PCB) other;
      return (others.getPid() == this.getPid());
    } else
      return false;
  }

  public int getOutstandingResourceRequests() {
    return outstandingResourceRequests;
  }

  public void setOutstandingResourceRequests(int totalResources) {
    this.outstandingResourceRequests = totalResources;
  }

}
